common.html = {
	/**
	 * Register the onload listener.
	 * @param {} fn
	 */
	onload : function(fn) {
		if (window.attachEvent)
			window.attachEvent('onload', fn);
		else if (window.addEventListener)
			window.addEventListener('load', fn, false);
		else
			window.addEventListener('load', fn);
	},
	/**
	 * 表单提交
	 * @param {} id
	 * @param {} action
	 * @param {} method
	 * @param {} target
	 * @param {} enctype
	 */
	formSubmit : function(arg) {
		var form = document.getElementById(id);
		if (arg.action != undefined) form.action = arg.action;
		if (arg.method != undefined) form.method = arg.method;
		if (arg.target != undefined) form.target = arg.target;
		if (arg.enctype != undefined) form.enctype = arg.enctype;
		form.submit();
	},
	/**
	 * 获取HTML对象
	 * @param {} id
	 * @return {}
	 */
	getObject : function(id) {
		return document.getElementById(id);
	},
	/**
	 * 设置对象是否可用
	 * @param {} object
	 * @param {} disabled
	 */
	disabled : function(object, disabled) {
		if (typeof(object) == 'object') {
			object.disabled = disabled;
		}
		if(typeof(object) == 'string') {
			var objects = document.getElementsByName(object);
			for (var i=0; i<objects.length; i++) {
				objects[i].disabled = disabled;
			}
		}
	},
	/**
	 * 清空组件值
	 * @param {} objectId
	 */
	clearValue : function(id) {
		document.getElementById(id).value = '';
	},
	/**
	 * checkbox
	 * example :
	 * <input type="checkbox" id="chkAll" onclick="checkAll('chk',this)" />
	 * <input type="checkbox" name="chk" />
	 * @param {} checkboxName
	 * @param {} checkAll
	 */
	checkAll : function(checkboxName, checkbox) {
		this.cAll(checkboxName, checkbox.checked);
	},
	cAll : function(checkboxName, checked) {
		var checkbox = document.getElementsByName(checkboxName);
		var count = checkbox.length;
		for (var i = 0; i < count; i++) {
			checkbox[i].checked = checked;
		}
	},
	getCheckedNum : function(checkboxName) {
		var checkbox = document.getElementsByName(checkboxName);
		var num = 0;
		var count = checkbox.length;
		for (var i = 0; i < count; i++) {
			if (checkbox[i].checked) {
				num++;
			}
		}
		return num;
	},
	getCheckedVal : function(checkboxName) {
		var checkbox = document.getElementsByName(checkboxName);
		var arr = [];
		var j = 0;
		var count = checkbox.length;
		for (var i = 0; i < count; i++) {
			if (checkbox[i].checked) {
				arr[arr.length] = checkbox[i].value;
			}
		}
		return arr;
	},
	/**
	 * 输入回车，指定控件获得焦点
	 * example :
	 * entry('elId',event)
	 * @param {} event
	 * @param {} elId
	 */
	entryTo : function(id, event) {
		var object = document.getElementById(id);
		event = event ? event : (window.event ? window.event : null);
		if (event.keyCode == 13) {
			object.focus();
		}
	},
	/**
	 * alert
	 * @param {} message
	 */
	alert : function(message) {
		alert(message);
	},
	/**
	 * confirm
	 * @param {} message
	 * @return {}
	 */
	confirm : function(message) {
		return confirm(message);
	},
	/**
	 * 打开窗口
	 * @param {} url
	 * @param {} options
	 * @return {}
	 */
	showDialog : function(url, options, arg) {
		return window.showModalDialog(url, arg, 'dialogWidth:'+options.width+'px;dialogHeight:'+options.height+'px;center:yes;help:no;scroll:yes;status:no;resizable:no');
	},
	/**
	 * 显示图片
	 * @param {} id
	 * @param {} url
	 * @param {} sizingMethod
	 * @param {} enabled
	 */
	showImage : function(id, url, sizingMethod, enabled) {
		var obj = document.getElementById(id);
		obj.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader()';
		if (enabled != undefined)
			obj.filters[0].enabled = enabled;
		if (sizingMethod != undefined)
			obj.filters[0].sizingMethod = sizingMethod;
		if (url != undefined)
			obj.filters[0].src = url;
	},
	/**
	 * 调整iframe高度
	 * @param {} id
	 * 使用方法：window.setInterval('id', 200);
	 */
	iframePack : function(id) {
		var iframe = window.top.document.getElementById(id);
		var bHeight = iframe.contentWindow.document.body.scrollHeight;
		var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
		var height = Math.max(bHeight, dHeight);
		iframe.height =  height;
	},
	/**
	 * 加入收藏
	 * <a href="javascript:void(null)" onclick="common.html.addBookmark(document.title, window.top.location.href)">收藏本站</a>
	 * @param {} title
	 * @param {} url
	 * @return {Boolean}
	 */
	addBookmark : function(title, url) {
		if (title == undefined) title = document.title;
		if (url == undefined) url = window.top.location.href;
		if (window.sidebar) {
			window.sidebar.addPanel(title, url, '');
		} else if(document.all) {
			window.external.AddFavorite(url, title);
		} else if(window.opera && window.print) {
			return true;
		}
	},
	/**
	 * 设为首页
	 * <a href="javascript:void(null)" onclick="common.html.setHomepage(this, window.top.location)">设为首页</a>
	 * @param {} obj
	 * @param {} url
	 */
	setHomepage : function(obj, url){
		if (obj == undefined) {
			event = event ? event : (window.event ? window.event : null);
			obj = event.srcElement;
		}
		if (url == undefined) url = window.top.location.href;
	    obj.style.behavior='url(#default#homepage)';
	    obj.setHomePage(url);
	}
};